#include <54func.h>
#include <iostream>
#include <workflow/WFFacilities.h>
#include <workflow/HttpMessage.h>
#include <workflow/HttpUtil.h>
using std::cout;
static WFFacilities::WaitGroup gWaitGroup(1); 
// 阻塞主线程，直到按下ctrl+c
void handler(int signum){
    printf("signum = %d\n", signum);
    gWaitGroup.done(); //计数器减一
}
int main(){
    signal(SIGINT,handler);
    cout << "1\n";
    // 利用工厂函数创建了一个任务
    WFHttpTask * httpTask =  WFTaskFactory::create_http_task(
                    "http://192.168.72.128:1234",10,0,nullptr);
    // 设置httpTask的属性 请求
    cout << "2\n";
    protocol::HttpRequest *req = httpTask->get_req();
    req->add_header_pair("Accept","*/*");
    // 将任务派给框架，由框架异步调用
    httpTask->start();
    cout << "3\n";
    gWaitGroup.wait(); // 等待直到计数器为0
}
